package org.jeecg.modules.health_records.past_operation.service.impl;

import org.jeecg.modules.health_records.past_operation.entity.PastOperationInfo;
import org.jeecg.modules.health_records.past_operation.mapper.PastOperationInfoMapper;
import org.jeecg.modules.health_records.past_operation.service.IPastOperationInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 手术史表
 * @Author: jeecg-boot
 * @Date:   2025-06-25
 * @Version: V1.0
 */
@Service
public class PastOperationInfoServiceImpl extends ServiceImpl<PastOperationInfoMapper, PastOperationInfo> implements IPastOperationInfoService {
    @Autowired
    private PastOperationInfoMapper pastOperationInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastOperationInfo> queryByRecordId(PastOperationInfo pastOperationInfo) {
        return pastOperationInfoMapper.queryByRecordId(Long.valueOf(pastOperationInfo.getRecordid()),pastOperationInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastOperationInfo> queryElecRecord(PastOperationInfo pastOperationInfo) {
        return pastOperationInfoMapper.queryElecRecord(Long.valueOf(pastOperationInfo.getRecordid()),pastOperationInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastOperationInfo> newQueryElecRecord(PastOperationInfo pastOperationInfo) {
        return pastOperationInfoMapper.newQueryElecRecord(Long.valueOf(pastOperationInfo.getRecordid()),pastOperationInfo.getSeeId(),pastOperationInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<PastOperationInfo> newQueryPastRecord(PastOperationInfo pastOperationInfo) {
        return pastOperationInfoMapper.newQueryPastRecord(Long.valueOf(pastOperationInfo.getRecordid()),pastOperationInfo.getSeeId(),pastOperationInfo.getIdNumber());

    }

}
